<style>
.panel-header{
	border-top:0px;
	border-left:0px;
	border-right:0px;
}
</style>
<div class="easyui-layout" data-options="fit: true">

	<div data-options="region: 'north', border: false" style="height: 120px; overflow: hidden;border-left:0;border-right:0;">
		<div class="easyui-layout" data-options="fit: true">
		
			<div data-options="region: 'center', title: '角色'" style="padding: 1px;border-left:0;border-right:0;">
				<div id="role"></div>
			</div>
			
		</div>
	</div>

	<div data-options="region: 'west', split: true, minWidth: 215, maxWidth: 500" style="width: 215px;border-top:0px;border-left:0;border-bottom:0;">
		<div class="easyui-layout" data-options="fit: true">
		
			<div data-options="region: 'center', title: '菜单权限'" style="padding: 1px;border-left:0;border-right:0;border-bottom:0;">
				<div id="menu_tree"></div>
			</div>
			
		</div>
	</div>
	
	<div class="centerLayout" data-options="region: 'center', title: '权限按钮', split: true, minWidth: 215, maxWidth: 500" style="width: 215px;border-bottom:0;border-right:0;">
		D
	</div>

</div>


<script>
	var $menu_tree;
	$(function(){
	
		$.post("${ctx}/manager/base/role/findRoleByIds", {"roleIds": "${roleIds!}"}, function(result) {
			if (result) {
				var role = $("#role");
				$.each(result, function(i, p){
					role.append(p.fullName+"&nbsp;&nbsp;&nbsp;");
				});
			} else {
				$.easyui.loaded();$.messager.alert("错误", "加载角色发生错误", "error");
			}
		}, 'json').error(function() { $.easyui.loaded(); });
	
		$menu_tree = $("#menu_tree").tree({
			method: "GET", url: "${ctx}/manager/system/menu/treegrid",
			animate: true, lines: true,
            onClick: function (node) {
            },
            onBeforeCollapse: function() {
            	//禁止折叠
            	return false ;
            },
            onLoadSuccess: function (node, data) {
            }
        });

	});
	
	//提交表单数据
	var submitNow = function($d, $dg, flag) {
		$.post(form_url, $("#form").form("getData"), function(result) {
			if (result.status) {
				$dg.datagrid('reload');alertify.success(result.message);$.easyui.loaded();
				if(flag==undefined||flag==false){$d.dialog("close") ;}
			} else {
				$.easyui.loaded();$.messager.alert("错误", result.message, "error");
			}
		}, 'json').error(function() { $.easyui.loaded(); });
	};
	
	//验证表单
	var submitForm = function($d, $dg, flag) { 
		if($('#form').form('validate')) {
			$.easyui.loading({ msg: "数据提交中，请稍等..." });
			submitNow($d, $dg, flag) ;
		}
	};
</script>

